package com.boilermaker.demo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@AllArgsConstructor
@Getter
public enum BookStatus {
    DELETED(0, "已删除"),
    NORMAL(1, "可借阅"),
    FORBIDDEN(2, "暂不可借阅");

    private Integer code;
    private String name;

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        return switch (code) {
            case 0 -> DELETED.getName();
            case 1 -> NORMAL.getName();
            case 2 -> FORBIDDEN.getName();
            default -> null;
        };
    }
}
